package com.bs.blogspace.controller;


import com.bs.blogspace.anno.Log;
import com.bs.blogspace.model.Result;
import com.bs.blogspace.pojo.AddSpace;
import com.bs.blogspace.service.AddSpaceService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Slf4j
public class AddSpaceController {

    @Autowired
    private AddSpaceService addSpaceService;


    @Log
    /*用户加入空间*/
    @PostMapping("/joinSpace")
    @ResponseBody
    public Result joinSpace(@RequestBody AddSpace addspace) {
        log.info("加入空间，{}", addspace);
        return addSpaceService.joinSpace(addspace);
    }

    /*查看指定用户已加入的空间*/
    @GetMapping("/getUserAddSpace")
    @ResponseBody
    public Result queryUserAddSpace(@Param("phone") String phone) {
        log.info("查看指定用户加入的空间，{}",phone);
        return addSpaceService.queryUserAddSpace(phone);
    }

    /*退出空间*/
    @PostMapping("/exitSpace")
    @ResponseBody
    public Result exitSpace(@RequestBody AddSpace addSpace){
        log.info("退出空间,{}",addSpace);
        return addSpaceService.exitSpace(addSpace);
    }
}
